package com.zzptc.zzsgz.bdsjws.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/13 0013.
 */

public class SOSAdapter extends RecyclerView.Adapter<SOSAdapter.MyViewHold>{
    List<Contact> list;
    public SOSAdapter(List<Contact> list){
        this.list=list;

    }
    @Override
    public MyViewHold onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.sos_contact_item,parent,false);
        MyViewHold myViewHold=new MyViewHold(view);

        return myViewHold;
    }

    @Override
    public void onBindViewHolder(MyViewHold holder, int position) {
        Contact contact=list.get(position);
        holder.tv_name.setText(contact.getName());
        holder.tv_tel.setText(contact.getPhonenum());
        holder.tv_addr.setText(contact.getAddress());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHold extends RecyclerView.ViewHolder{
        @BindView(R.id.tv_sos_addr)
        TextView tv_addr;
        @BindView(R.id.tv_sos_tel)
        TextView tv_tel;
        @BindView(R.id.tv_sos_name)
        TextView tv_name;
        public MyViewHold(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
